package com.model.user;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.TableGenerator;

import com.core.protocols.IKVObject;
import com.core.utils.KeyValueDictionary;
import com.core.utils.LocalizableString;
import com.model.KeyValue;

@Entity
public class UserGroup
        implements IKVObject {

	private Integer id;
	private String  name;
	private String  description;



	@Id
	@TableGenerator(name = "generatorUserGroup", table = "Generators", pkColumnName = "generatorName", pkColumnValue = "generatorUserGroup", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "generatorUserGroup")
	public Integer getId () {

		return id;
	}



	public void setId ( Integer id ) {

		this.id = id;
	}



	public String getName () {

		return name;
	}



	public void setName ( String name ) {

		this.name = name;
	}



	@Lob
	public String getDescription () {

		return description;
	}



	public void setDescription ( String description ) {

		this.description = description;
	}



	public KeyValueDictionary toDictionary () {

		KeyValueDictionary result = new KeyValueDictionary();
		return result;
	}



	@Override
	public void assignTo ( IKVObject object ) {

		UserGroup group = (UserGroup) object;
		group.setDescription(this.getDescription());
		group.setName(this.getName());

	}



	@Override
	public KeyValue idValue () {

		String strIdValue = this.getId().toString();
		return new KeyValue(this.fieldNameAsId(), strIdValue, false);

	}



	@Override
	public String fieldNameAsId () {

		return "id";
	}



	@Override
	public KeyValue nameValue () {

		String strIdValue = this.getName().toString();
		return new KeyValue(this.fieldNameAsName(), strIdValue, false);

	}



	@Override
	public String fieldNameAsName () {

		return "name";
	}



	public String localizableDescription () {

		return LocalizableString.sharedInstance().localizable("entity.UserGroup.description");
	}
}
